<template>
	<view class="content">
		<u-gap height="10" bgColor="#f4f4f4"></u-gap>
		<view v-if="current == 1">
			<view class="dis_f_l_c" style="padding: 20rpx;">
				<view class="tags_item" @click="item_change(index)" :class="active == index ?'item1':'item2'"
					v-for="(item,index) in tagList">
					{{item}}
				</view>
			</view>
			<BuyList :list="qg_list" @getQiugou="get_qiugou"></BuyList>
		</view>

		<view v-else>
			<GoodsList :list="goodsList" @getGoods="get_goods" />
		</view>
	</view>
</template>
<script>
	import BuyList from "@/pages/person/components/BuyList.vue";
	import GoodsList from "@/pages/person/components/GoodsLists.vue";
	export default {

		components: {

			BuyList,
			GoodsList
		},
		data() {
			return {
				current: 0,
				page: 1,
				total: 0,
				goodsList: [],
				qg_list: [],
				status: -1,
				active: 0,
				list1: [{
						name: "商品",
					},
					{
						name: "求购",
					},
				],
				tagList: ["全部", "求购中", "已完成", "已过期"],
			};
		},
		onLoad(options) {
			this.get_goods()
			// this.current = options.current;
			console.log(this.current)

		},
		onReachBottom() {
			console.log(111)
			if (this.page < this.total) {
				this.page++
				if (this.current == 0) {
					this.get_goods()
				}
			}
		},
		methods: {
			get_goods() {
				this.$.ajax(1, "POST", "user/getmyfoot", {
					page: this.page

				}, (res) => {
					if (res.code == 1) {
						this.total = res.data.total
						if (this.page == 1) {
							this.goodsList = []
						}
						this.goodsList = [...this.goodsList, ...res.data.list]
					} else {
						this.$.ti_shi(res.msg)
					}
				})
			},
			click(val) {
				this.current = val.index;
				this.page = 1
				if (this.current == 0) {

					this.get_goods()
				}
				if (this.current == 1) {

					this.get_qiugou()
				}
			},
		},
		created() {},
		mounted() {},
	};
</script>
<style lang="scss" scoped>
	.item2 {
		background-color: #F2F2F2;

	}

	.item1 {
		background-color: #EBF5FF;
		color: #016FDD;
		font-weight: bold;
	}

	.tags_item {
		padding: 10rpx 28rpx;

		margin-right: 20rpx;
		font-size: 26rpx;
		border-radius: 30rpx;
	}

	.content {
		background-color: #fff;

		// padding-left: 20rpx;
		.box {
			padding: 20rpx 20rpx 0;
		}
	}
</style>